package com.neusoft.databus.policy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;

import lombok.Getter;
import lombok.Setter;

/**
 * 联动资源关联实体
 *
 * @author naxiang
 */
@Getter
@Setter
@Entity
public class PolicyRefLinkage extends AbstractAuditModel {
    private static final long serialVersionUID = 1118057548553563264L;

    /** 资源编码 */
    @Length(max = 50, message = "资源编码不能超过{max}位")
    @Column(length = 50)
    private String resourceCode;

    /** 控制指标，逗号分隔 */
    @Length(max = 1023, message = "控制指标{max}位")
    @Column(length = 1023)
    private String controlUsageMetrics;

    /** 解除控制指标，逗号分隔 */
    @Length(max = 1023, message = "解除控制指标不能超过{max}位")
    @Column(length = 1023)
    private String cancelUsageMetrics;

    /**
     * 策略
     */
    @ManyToOne(targetEntity = Policy.class)
    @LazyCollection(LazyCollectionOption.FALSE)
    @JoinColumn(name = "policy_id")
    private Policy policy;
}
